package top.shiyiri.community.util;

import org.springframework.stereotype.Component;
import top.shiyiri.community.bean.User;

/**
 * 持有用户的信息，用于代替 session 对象
 * @author Aunean
 * @date 2022/3/14 20:10
 */
@Component
public class HostHolder {

    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }

    public void clear() {
        users.remove();
    }

}
